
package com.rs.controller.Rs;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;

import com.rs.model.CommonResult;
import com.rs.model.Progress;
import com.rs.model.Project;
import com.rs.service.rs.ProgressService;
import com.rs.service.rs.ProjectService;
import com.rs.util.ImagePanel;
import com.rs.util.SpringContextUtils;
import com.rs.util.TimeTypeConversionUtil;

public class ProjectJFrame extends JInternalFrame {

	private static final long serialVersionUID = 1L;

	public ProjectJFrame() {
		//设置是否允许自由调整大小
		setResizable(true);

		//设置是否提供“最大化”按钮
		setMaximizable(true);

		//设置是否提供“最小化”按钮
		setIconifiable(true);

		//设置是否提供关闭按钮
		setClosable(true);
		getContentPane().setLayout(null);

		setVisible(true);
	}

	public void alert(String alert) {
		JOptionPane.showMessageDialog(this, alert);

	}

	/******************查询项目*********************/
	class ProJFrame extends ProjectJFrame {

		private ProjectService pros = SpringContextUtils.getBean(ProjectService.class);

		private Project project = new Project();

		private JPanel contentPane;

		private JTable table;

		// 表头（列名）
		private Object[] columnNames = { "ID", "上传人", "项目名称", "文档名称", "上传时间", "项目状态", "操作" };

		private DefaultTableModel dtable;

		private JLabel show;//显示分页

		private Integer pageNum;//当前页

		private Integer pages;//总页数

		private JTextField prname;//项目名字

		private JTextField uname;//负责人名字

		private JComboBox<String> protype;//项目状态

		Map<String, Integer> mapde = new HashMap<>();
		Map<String, Integer> mappo = new HashMap<>();

		private static final long serialVersionUID = 1L;

		public ProJFrame(final JDesktopPane q) {
			super();
			//设置标题
			setTitle("项目记录");
			//设置是否允许自由调整大小
			setResizable(false);
			//设置最大化
			setMaximizable(false);
			//设置大小
			setBounds(40, 35, 800, 550);
			//主体
			contentPane = new ImagePanel(800, 550, "twwe2.jpg");
			contentPane.setLayout(null);
			setContentPane(contentPane);

			//创建1个字体实例
			Font font = new Font("宋体", Font.BOLD, 14);
			//初始化当前页数为
			project.setPageNum(1);
			//查询所有的
			CommonResult<Map<String, Object>> projects = pros.projectConditionsQueryPc(project);

			//为当前页赋值
			if (Optional.ofNullable(projects.getData().get("pageNum")).isPresent()) {

				pageNum = (Integer) projects.getData().get("pageNum");
			} else {
				pageNum = 1;
			}
			//总条数
			//total = (Integer) users.getData().get("total");
			//总页数
			if (Optional.ofNullable(projects.getData().get("pages")).isPresent()) {
				pages = (Integer) projects.getData().get("pages");
			} else {
				pages = 1;
			}
			//转为list
			// 创建一个表格，指定 所有行数据 和 表头
			dtable = new DefaultTableModel(getObjectArys(projects), columnNames);

			table = new JTable(dtable) {
				private static final long serialVersionUID = 1L;

				//设置表格为不可编辑
				@Override
				public boolean isCellEditable(int row, int column) {
					return false;
				}
			};
			//设置行高
			table.setRowHeight(25);
			table.setFont(font);
			table.getTableHeader().setBounds(20, 90, 750, 25);
			table.setBounds(20, 120, 750, 300);
			//表头不可拖动
			table.getTableHeader().setReorderingAllowed(false);
			//设置是否可以选择此模型中的行。 
			table.setRowSelectionAllowed(true);
			//设置表格为不可编辑
			//table.isCellEditable(uList.size(), 6);
			//设置只能选择一行
			table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

			// 把 表头 添加到容器顶部（使用普通的中间容器添加表格时，表头 和 内容 需要分开添加）
			contentPane.add(table.getTableHeader(), null);
			// 把 表格内容 添加到容器中心
			contentPane.add(table, null);

			//表格的点击事件

			table.addMouseListener(new MouseAdapter() {

				@Override
				public void mouseClicked(MouseEvent e) {
					if (e.getClickCount() == 2) {
						// 处理鼠标双击
						int row = table.getSelectedRow();
						String pId = table.getValueAt(row, 0).toString(); //得到所在行的第一个列的值，作为下面事件传递的参数
						try {
							//使窗口图标化
							setIcon(true);
						} catch (PropertyVetoException e1) {

							e1.printStackTrace();
						}
						q.add(new ProjectJFrame().new DetailsProject(pId, q));
					}
				}

			});

			//分页

			show = new JLabel();
			show.setText("当前页：" + pageNum + " / 总页数：" + pages);
			show.setFont(new Font("宋体", Font.BOLD, 15));
			show.setBounds(300, 420, 200, 30);
			contentPane.add(show, null);

			final JButton fore = new JButton("首  页");
			fore.setBounds(100, 475, 80, 28);
			fore.setFont(font);
			contentPane.add(fore, null);
			fore.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					String type = fore.getText();
					paging(type);

				}
			});

			final JButton previous = new JButton("上一页");
			previous.setBounds(280, 475, 80, 28);
			previous.setFont(font);
			contentPane.add(previous, null);
			previous.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					String type = previous.getText();
					paging(type);
				}
			});

			final JButton later = new JButton("下一页");
			later.setBounds(470, 475, 80, 28);
			later.setFont(font);
			contentPane.add(later, null);
			later.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					String type = later.getText();
					paging(type);

				}
			});

			final JButton aft = new JButton("尾  页");
			aft.setBounds(630, 475, 80, 28);
			aft.setFont(font);
			contentPane.add(aft, null);
			aft.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					String type = aft.getText();
					paging(type);

				}
			});

			prname = new JTextField("项目名", 10);
			prname.setBounds(130, 10, 90, 20);
			prname.setFont(font);
			contentPane.add(prname, null);

			uname = new JTextField("负责人", 10);
			uname.setBounds(20, 10, 90, 20);
			uname.setFont(font);
			contentPane.add(uname, null);

			//审核
			String[] audytArr = new String[] { "项目状态", "立项", "执行", "交付", "延期", "中止" };
			protype = new JComboBox<String>(audytArr);
			protype.setBounds(240, 10, 90, 20);
			protype.setFont(font);
			contentPane.add(protype);

			//查询按钮
			JButton query = new JButton("查询");
			query.setBounds(590, 10, 70, 20);
			query.setFont(font);
			contentPane.add(query);
			query.addActionListener(new ActionListener() {

				@Override
				public void actionPerformed(ActionEvent e) {
					//姓名
					if (!prname.getText().equals("项目名")) {

						project.setPr_name(prname.getText());
					}
					//部门id
					if (!uname.getText().equals("负责人")) {

						project.setPr_uname(uname.getText());

					}

					//审核状态
					String auditString = (String) protype.getSelectedItem();
					if (!auditString.equals("项目状态")) {
						switch (auditString) {
						case "立项":
							project.setPr_post(0);
							break;
						case "执行":
							project.setPr_post(1);
							break;
						case "交付":
							project.setPr_post(2);
							break;
						case "延期":
							project.setPr_post(3);
							break;
						case "中止":
							project.setPr_post(4);
							break;

						}
					}

					//查询
					//设置当前页为1
					project.setPageNum(1);
					CommonResult<Map<String, Object>> result = pros.projectConditionsQueryPc(project);
					Object[][] shouye = getObjectArys(result);
					//使用数组 dataVector的值替换 dataVector实例变量中的值。 
					dtable.setDataVector(shouye, columnNames);
					table.setModel(dtable);
					pageNum = (Integer) result.getData().get("pageNum");
					pages = (Integer) result.getData().get("pages");
					show.setText("当前页：" + pageNum + " / 总页数：" + pages);

				}
			});

			//重置按钮
			JButton reset = new JButton("重置");
			reset.setBounds(680, 10, 70, 20);
			reset.setFont(font);
			contentPane.add(reset);
			reset.addActionListener(new ActionListener() {

				@Override
				public void actionPerformed(ActionEvent e) {
					//重置
					reset();
				}
			});

		}

		public void paging(String type) {
			switch (type) {
			case "首  页":
				project.setPageNum(1);
				CommonResult<Map<String, Object>> ufore = pros.projectConditionsQueryPc(project);
				Object[][] shouye = getObjectArys(ufore);
				//使用数组 dataVector的值替换 dataVector实例变量中的值。 
				dtable.setDataVector(shouye, columnNames);
				table.setModel(dtable);
				pageNum = (Integer) ufore.getData().get("pageNum");
				pages = (Integer) ufore.getData().get("pages");
				show.setText("当前页：" + pageNum + " / 总页数：" + pages);
				break;
			case "上一页":
				//当前页减1
				int previousNum = pageNum - 1;
				if (previousNum < 1) {
					alert("当前已是首页");
					previousNum = 1;
				}
				project.setPageNum(previousNum);
				CommonResult<Map<String, Object>> upreviou = pros.projectConditionsQueryPc(project);
				Object[][] shangyi = getObjectArys(upreviou);

				//使用数组 dataVector的值替换 dataVector实例变量中的值。 
				dtable.setDataVector(shangyi, columnNames);
				table.setModel(dtable);
				pageNum = (Integer) upreviou.getData().get("pageNum");
				pages = (Integer) upreviou.getData().get("pages");
				show.setText("当前页：" + pageNum + " / 总页数：" + pages);

				break;
			case "下一页":
				//当前页加1
				int laterNum = pageNum + 1;

				if (laterNum > pages) {
					alert("当前已是尾页");
					laterNum = pages;
				}

				project.setPageNum(laterNum);
				CommonResult<Map<String, Object>> ulater = pros.projectConditionsQueryPc(project);

				Object[][] xiayiye = getObjectArys(ulater);

				//使用数组 dataVector的值替换 dataVector实例变量中的值。 
				dtable.setDataVector(xiayiye, columnNames);
				table.setModel(dtable);
				pageNum = (Integer) ulater.getData().get("pageNum");
				pages = (Integer) ulater.getData().get("pages");
				show.setText("当前页：" + pageNum + " / 总页数：" + pages);
				break;
			case "尾  页":
				project.setPageNum(pages);
				CommonResult<Map<String, Object>> uaft = pros.projectConditionsQueryPc(project);
				Object[][] weiye = getObjectArys(uaft);
				//使用数组 dataVector的值替换 dataVector实例变量中的值。 
				dtable.setDataVector(weiye, columnNames);
				table.setModel(dtable);
				pageNum = (Integer) uaft.getData().get("pageNum");
				pages = (Integer) uaft.getData().get("pages");
				show.setText("当前页：" + pageNum + " / 总页数：" + pages);
				break;
			}
		}

		public Object[][] getObjectArys(CommonResult<Map<String, Object>> projects) {
			@SuppressWarnings("unchecked")
			List<Project> pList = (List<Project>) projects.getData().get("list");

			Object[][] rowData = new Object[pList.size()][];
			for (int i = 0, n = pList.size(); i < n; i++) {
				Project project = pList.get(i);
				rowData[i] = project.toObjects(columnNames.length);
			}
			return rowData;
		}

		//重置
		public void reset() {

			prname.setText("项目名");

			uname.setText("负责人");

			protype.setSelectedIndex(0);

			project.setPr_name(null);
			project.setPr_uname(null);
			project.setPr_post(null);

		}

	}

	/****************查看项目详情***********/
	class DetailsProject extends ProjectJFrame {

		private static final long serialVersionUID = 1L;

		private JPanel contentPane;

		private ProjectService pros = SpringContextUtils.getBean(ProjectService.class);

		private ProgressService pgs = SpringContextUtils.getBean(ProgressService.class);

		private JTextField text_id;//id

		private JTextField text_name;//项目名

		private JTextField text_uname;//负责人

		private JTextArea text_brief;//项目简介

		private JTextField text_time;//开始时间

		private JTextField text_day;//项目天数

		private JTextField text_schedule;//项目进度

		private JTextField text_post;//项目状态

		private JTable table;

		private DefaultTableModel dtable;

		private Progress progress = new Progress();

		private JLabel show;//显示分页

		private Integer pageNum;//当前页

		private Integer pages;//总页数

		// 表头（列名）
		private Object[] columnNames = { "ID", "成员姓名", "职位", "项目占比", "个人进度", "操作" };

		public DetailsProject(String pid, final JDesktopPane q) {

			super();
			//使窗体只有一个界面
			JInternalFrame[] jif = q.getAllFrames();
			if (jif.length >= 2) {
				jif[0].dispose();
			}
			//设置标题
			setTitle("项目详情");
			//设置是否允许自由调整大小
			setResizable(false);
			//设置最大化
			setMaximizable(false);
			//设置大小
			setBounds(150, 15, 580, 600);

			contentPane = new ImagePanel(580, 600, "twwe2.jpg");
			contentPane.setLayout(null);
			setContentPane(contentPane);

			//查询
			Project project = pros.projectQueryOnePc(Integer.valueOf(pid)).getData();

			//初始化字体
			Font font = new Font("宋体", Font.BOLD, 15);
			//项目名称:
			JLabel name = new JLabel("项目名称:");
			name.setFont(font);
			name.setBounds(50, 30, 75, 20);
			text_name = new JTextField(project.getPr_name());
			text_name.setFont(font);
			text_name.setBounds(130, 30, 80, 20);
			//禁止编辑
			text_name.setEditable(false);
			contentPane.add(name);
			contentPane.add(text_name);

			//项目ID
			JLabel id = new JLabel("项目ID:");
			id.setFont(font);
			id.setBounds(50, 60, 75, 20);
			text_id = new JTextField(String.valueOf(project.getPr_id()));
			text_id.setFont(font);
			text_id.setBounds(130, 60, 80, 20);
			//禁止编辑
			text_id.setEditable(false);
			contentPane.add(id);
			contentPane.add(text_id);

			//项目简介
			JLabel brief = new JLabel("项目简介:");
			brief.setFont(font);
			brief.setBounds(50, 90, 75, 20);
			text_brief = new JTextArea(" " + " " + project.getPr_brief());
			text_brief.setFont(new Font("宋体", Font.PLAIN, 14));
			text_brief.setBounds(50, 115, 150, 80);
			//设置自动换行
			text_brief.setLineWrap(true);
			//text_brief.setBackground(Color.gray);
			//禁止编辑
			text_brief.setEditable(false);
			contentPane.add(brief);
			contentPane.add(text_brief);

			JLabel participate = new JLabel("参与人：");
			participate.setFont(font);
			participate.setBounds(50, 200, 75, 20);
			contentPane.add(participate);

			//负责人
			JLabel uname = new JLabel("负责人:");
			uname.setFont(font);
			uname.setBounds(300, 30, 75, 20);
			text_uname = new JTextField(project.getPr_uname());
			text_uname.setFont(font);
			text_uname.setBounds(380, 30, 80, 20);
			//禁止编辑
			text_uname.setEditable(false);
			contentPane.add(uname);
			contentPane.add(text_uname);

			//开始时间
			JLabel time = new JLabel("开始时间:");
			time.setFont(font);
			time.setBounds(300, 60, 75, 20);
			text_time = new JTextField(TimeTypeConversionUtil.getStringDate(project.getPr_ktime()));
			text_time.setFont(font);
			text_time.setBounds(380, 60, 100, 20);
			//禁止编辑
			text_time.setEditable(false);
			contentPane.add(time);
			contentPane.add(text_time);

			//项目天数
			JLabel day = new JLabel("项目天数:");
			day.setFont(font);
			day.setBounds(300, 90, 75, 20);
			text_day = new JTextField(String.valueOf(project.getPr_days()));
			text_day.setFont(font);
			text_day.setBounds(380, 90, 80, 20);
			//禁止编辑
			text_day.setEditable(false);
			contentPane.add(day);
			contentPane.add(text_day);

			//项目进度
			JLabel schedule = new JLabel("项目进度:");
			schedule.setFont(font);
			schedule.setBounds(300, 120, 75, 20);
			text_schedule = new JTextField(String.valueOf(project.getPr_schedule()));
			text_schedule.setFont(font);
			text_schedule.setBounds(380, 120, 80, 20);
			//禁止编辑
			text_schedule.setEditable(false);
			contentPane.add(schedule);
			contentPane.add(text_schedule);

			//项目状态
			JLabel post = new JLabel("项目状态:");
			post.setFont(font);
			post.setBounds(300, 150, 75, 20);
			String pr_post = "";
			switch (project.getPr_post()) {
			case 0:
				pr_post = "立项";
				break;
			case 1:
				pr_post = "执行";
				break;
			case 2:
				pr_post = "交付";
				break;
			case 3:
				pr_post = "延期";
				break;

			case 4:
				pr_post = "中止";
				break;

			}
			text_post = new JTextField(pr_post);
			text_post.setFont(font);
			text_post.setBounds(380, 150, 80, 20);
			//禁止编辑
			text_post.setEditable(false);
			contentPane.add(post);
			contentPane.add(text_post);

			//参与人列表
			//查询所有
			//首页为一
			progress.setPageNum(1);
			progress.setPre_prid(Integer.valueOf(pid));
			CommonResult<Map<String, Object>> allPc = pgs.progressQueryProjectAllPc(progress);

			//为当前页赋值
			if (Optional.ofNullable(allPc.getData().get("pageNum")).isPresent()) {

				pageNum = (Integer) allPc.getData().get("pageNum");
			} else {
				pageNum = 1;
			}
			//总条数
			//total = (Integer) users.getData().get("total");
			//总页数
			if (Optional.ofNullable(allPc.getData().get("pages")).isPresent()) {
				pages = (Integer) allPc.getData().get("pages");
			} else {
				pages = 1;
			}

			// 创建一个表格，指定 所有行数据 和 表头
			dtable = new DefaultTableModel(getObjectArys(allPc), columnNames);

			table = new JTable(dtable) {
				private static final long serialVersionUID = 1L;

				//设置表格为不可编辑
				@Override
				public boolean isCellEditable(int row, int column) {
					return false;
				}
			};
			//设置行高
			table.setRowHeight(25);
			table.setFont(font);
			table.getTableHeader().setBounds(40, 230, 500, 25);
			table.setBounds(40, 255, 500, 250);
			//表头不可拖动
			table.getTableHeader().setReorderingAllowed(false);
			//设置是否可以选择此模型中的行。 
			table.setRowSelectionAllowed(true);
			//设置表格为不可编辑
			//table.isCellEditable(uList.size(), 6);
			//设置只能选择一行
			table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

			// 把 表头 添加到容器顶部（使用普通的中间容器添加表格时，表头 和 内容 需要分开添加）
			contentPane.add(table.getTableHeader(), null);
			// 把 表格内容 添加到容器中心
			contentPane.add(table, null);

			//表格的点击事件

			table.addMouseListener(new MouseAdapter() {

				@Override
				public void mouseClicked(MouseEvent e) {
					if (e.getClickCount() == 2) {
						// 处理鼠标双击
						int row = table.getSelectedRow();
						String pId = table.getValueAt(row, 0).toString(); //得到所在行的第一个列的值，作为下面事件传递的参数
						try {
							//使窗口图标化
							setIcon(true);
						} catch (PropertyVetoException e1) {

							e1.printStackTrace();
						}
						q.add(new ProjectJFrame().new DetailsProress(pId, q));
					}
				}

			});

			//分页

			show = new JLabel();
			show.setText("当前页：" + pageNum + " / 总页数：" + pages);
			show.setFont(new Font("宋体", Font.BOLD, 15));
			show.setBounds(300, 420, 200, 30);
			contentPane.add(show, null);

			Font feye = new Font("宋体", Font.PLAIN, 12);

			final JButton fore = new JButton("首  页");
			fore.setBounds(40, 520, 80, 25);
			fore.setFont(feye);
			contentPane.add(fore, null);
			fore.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					String type = fore.getText();
					paging(type);

				}
			});

			final JButton previous = new JButton("上一页");
			previous.setBounds(175, 520, 80, 25);
			previous.setFont(feye);
			contentPane.add(previous, null);
			previous.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					String type = previous.getText();
					paging(type);
				}
			});

			final JButton later = new JButton("下一页");
			later.setBounds(330, 520, 80, 25);
			later.setFont(feye);
			contentPane.add(later, null);
			later.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					String type = later.getText();
					paging(type);

				}
			});

			final JButton aft = new JButton("尾  页");
			aft.setBounds(460, 520, 80, 25);
			aft.setFont(feye);
			contentPane.add(aft, null);
			aft.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					String type = aft.getText();
					paging(type);

				}
			});

		}

		public void paging(String type) {
			switch (type) {
			case "首  页":
				progress.setPageNum(1);
				CommonResult<Map<String, Object>> ufore = pgs.progressQueryProjectAllPc(progress);
				Object[][] shouye = getObjectArys(ufore);
				//使用数组 dataVector的值替换 dataVector实例变量中的值。 
				dtable.setDataVector(shouye, columnNames);
				table.setModel(dtable);
				pageNum = (Integer) ufore.getData().get("pageNum");
				pages = (Integer) ufore.getData().get("pages");
				show.setText("当前页：" + pageNum + " / 总页数：" + pages);
				break;
			case "上一页":
				//当前页减1
				int previousNum = pageNum - 1;
				if (previousNum < 1) {
					alert("当前已是首页");
					previousNum = 1;
				}
				progress.setPageNum(previousNum);
				CommonResult<Map<String, Object>> upreviou = pgs.progressQueryProjectAllPc(progress);
				Object[][] shangyi = getObjectArys(upreviou);

				//使用数组 dataVector的值替换 dataVector实例变量中的值。 
				dtable.setDataVector(shangyi, columnNames);
				table.setModel(dtable);
				pageNum = (Integer) upreviou.getData().get("pageNum");
				pages = (Integer) upreviou.getData().get("pages");
				show.setText("当前页：" + pageNum + " / 总页数：" + pages);

				break;
			case "下一页":
				//当前页加1
				int laterNum = pageNum + 1;

				if (laterNum > pages) {
					alert("当前已是尾页");
					laterNum = pages;
				}

				progress.setPageNum(laterNum);
				CommonResult<Map<String, Object>> ulater = pgs.progressQueryProjectAllPc(progress);

				Object[][] xiayiye = getObjectArys(ulater);

				//使用数组 dataVector的值替换 dataVector实例变量中的值。 
				dtable.setDataVector(xiayiye, columnNames);
				table.setModel(dtable);
				pageNum = (Integer) ulater.getData().get("pageNum");
				pages = (Integer) ulater.getData().get("pages");
				show.setText("当前页：" + pageNum + " / 总页数：" + pages);
				break;
			case "尾  页":
				progress.setPageNum(pages);
				CommonResult<Map<String, Object>> uaft = pgs.progressQueryProjectAllPc(progress);
				Object[][] weiye = getObjectArys(uaft);
				//使用数组 dataVector的值替换 dataVector实例变量中的值。 
				dtable.setDataVector(weiye, columnNames);
				table.setModel(dtable);
				pageNum = (Integer) uaft.getData().get("pageNum");
				pages = (Integer) uaft.getData().get("pages");
				show.setText("当前页：" + pageNum + " / 总页数：" + pages);
				break;
			}
		}

		public Object[][] getObjectArys(CommonResult<Map<String, Object>> processes) {
			@SuppressWarnings("unchecked")
			List<Progress> pList = (List<Progress>) processes.getData().get("list");

			Object[][] rowData = new Object[pList.size()][];
			for (int i = 0, n = pList.size(); i < n; i++) {
				Progress progress = pList.get(i);
				rowData[i] = progress.toObjects(columnNames.length);
			}
			return rowData;
		}

	}

	/******************进度详情*********/
	class DetailsProress extends ProjectJFrame {

		private static final long serialVersionUID = 1L;

		private JPanel contentPane;

		private ProgressService pgs = SpringContextUtils.getBean(ProgressService.class);

		private JTextField text_id;//id

		private JTextField text_prname;//项目名

		private JTextField text_uname;//组员姓名

		private JTextField text_po;//职位

		private JTextField text_one;//个人进度

		private JTextField text_all;//项目进度

		private JTextField text_time;//汇报时间

		private JTextArea text_content;//汇报内容

		public DetailsProress(String pid, JDesktopPane q) {
			//使窗体只有一个界面
			JInternalFrame[] jif = q.getAllFrames();
			if (jif.length >= 2) {
				jif[0].dispose();
			}
			//设置标题
			setTitle("进度详情");
			//设置是否允许自由调整大小
			setResizable(false);
			//设置最大化
			setMaximizable(false);
			//设置大小
			setBounds(180, 120, 540, 320);

			contentPane = new ImagePanel(540, 320, "twwe2.jpg");
			contentPane.setLayout(null);
			setContentPane(contentPane);

			//查询

			Progress progress = pgs.progressQueryDetailApp(Integer.valueOf(pid)).getData();

			//初始化字体
			Font font = new Font("宋体", Font.BOLD, 15);
			//项目名称:
			JLabel prname = new JLabel("项目名称:");
			prname.setFont(font);
			prname.setBounds(50, 30, 75, 20);
			text_prname = new JTextField(progress.getPre_prname());
			text_prname.setFont(font);
			text_prname.setBounds(130, 30, 80, 20);
			//禁止编辑
			text_prname.setEditable(false);
			contentPane.add(prname);
			contentPane.add(text_prname);

			//项目ID
			JLabel id = new JLabel("进度ID:");
			id.setFont(font);
			id.setBounds(50, 60, 75, 20);
			text_id = new JTextField(String.valueOf(progress.getPre_id()));
			text_id.setFont(font);
			text_id.setBounds(130, 60, 80, 20);
			//禁止编辑
			text_id.setEditable(false);
			contentPane.add(id);
			contentPane.add(text_id);

			//组员姓名
			JLabel uname = new JLabel("组员姓名:");
			uname.setFont(font);
			uname.setBounds(50, 90, 75, 20);
			text_uname = new JTextField(progress.getPre_uname());
			text_uname.setFont(font);

			text_uname.setBounds(130, 90, 80, 20);
			//禁止编辑
			text_uname.setEditable(false);
			contentPane.add(uname);
			contentPane.add(text_uname);

			//职位
			JLabel po = new JLabel("职位:");
			po.setFont(font);
			po.setBounds(50, 120, 75, 20);
			String potype = null;
			if (Optional.ofNullable(progress.getPre_potype()).isPresent()) {
				switch (progress.getPre_potype()) {
				case 0:
					potype = "UI";
					break;
				case 1:
					potype = "Java后台";
					break;
				case 2:
					potype = "php后台";
					break;
				case 3:
					potype = "前端";
					break;
				case 4:
					potype = "安卓";
					break;
				case 5:
					potype = "IOS";
					break;
				}
			}

			text_po = new JTextField(potype);
			text_po.setFont(font);

			text_po.setBounds(130, 120, 80, 20);
			//禁止编辑
			text_po.setEditable(false);
			contentPane.add(po);
			contentPane.add(text_po);

			//个人进度
			JLabel one = new JLabel("个人进度:");
			one.setFont(font);
			one.setBounds(300, 30, 75, 20);
			text_one = new JTextField(String.valueOf(progress.getPre_schedule()) + "%");
			text_one.setFont(font);
			text_one.setBounds(380, 30, 80, 20);
			//禁止编辑
			text_one.setEditable(false);
			contentPane.add(one);
			contentPane.add(text_one);

			//开始时间
			JLabel all = new JLabel("项目进度:");
			all.setFont(font);
			all.setBounds(300, 60, 75, 20);
			text_all = new JTextField(String.valueOf(progress.getPre_totalsche()) + "%");
			text_all.setFont(font);
			text_all.setBounds(380, 60, 80, 20);
			//禁止编辑
			text_all.setEditable(false);
			contentPane.add(all);
			contentPane.add(text_all);

			//项目时间
			JLabel time = new JLabel("汇报时间:");
			time.setFont(font);
			time.setBounds(300, 90, 75, 20);
			text_time = new JTextField(TimeTypeConversionUtil.getStringDate(progress.getPre_time()));
			text_time.setFont(font);
			text_time.setBounds(380, 90, 100, 20);
			//禁止编辑
			text_time.setEditable(false);
			contentPane.add(time);
			contentPane.add(text_time);

			//项目进度
			JLabel content = new JLabel("汇报内容:");
			content.setFont(font);
			content.setBounds(50, 150, 75, 20);
			text_content = new JTextArea(" " + " " + progress.getPre_content());
			text_content.setFont(new Font("宋体", Font.PLAIN, 14));
			text_content.setBounds(50, 180, 150, 80);
			//禁止编辑
			text_content.setEditable(false);
			//设置自动换行
			text_content.setLineWrap(true);
			contentPane.add(content);
			contentPane.add(text_content);

		}

	}
}
